function playSFX(id) {
	var sfx = document.getElementById(id);
	if (!sfx) return;

	sfx.load();
	sfx.play();

	log("play a: "+ id);
}

function loadSFX(id, src) {
	var sfx = document.createElement("audio");
	sfx.id = id;
	sfx.src = src;

	document.body.appendChild(sfx);

	log("load a: "+ id);
}

var sfxResources = [
	["sfx0", "sfx/sound6.mp3", ".sfx", "load"],
	["sfx1", "sfx/sound6.mp3", ".sfx", "click"],
//	["sfx2", "sfx/sound6.mp3", ".sfx", "vmousedown"],
//	["sfx3", "sfx/sound6.mp3", ".sfx", "vmouseup"],
//	["sfx4", "sfx/sound6.mp3", ".sfx", "vmousemove"],
];

function log(message) {
	document.body.appendChild(document.createTextNode(message));
	document.body.appendChild(document.createElement("br"));
}

function setupSFX() {
//	loadSFX("sound6", "sfx/sound6.mp3");
//	$(".sfx_click").click(function() { playSFX("sound6"); });
//	$(".sfx").bind("click", function() { playSFX(sfxResource[0]); });

	for (sfxResource in sfxResources) {
		(function(sfx) {
			loadSFX(sfx[0], sfx[1]);
			$(sfx[2]).bind(sfx[3], function() {	playSFX(sfx[0]); });
		})(sfxResources[sfxResource])
	}
}

$(document).ready(function () {
	setupSFX();
	playSFX("sfx0");
});

function soundPlay(sound) {
	var audio = new Audio(sound);
	audio.load();
	audio.play();

	log("play b: "+ sound);
}

function cloneSound(id) {
	var audio = document.getElementById(id);
	if (!audio) return;

	var clone = audio.cloneNode(true);
	clone.play();

	log("play c: "+ clone.src)
}
